<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <title>管理收货地址</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <script src="__ROOT__/static/home/js/shop/rem.js"></script>
    <script type="text/javascript" src="__ROOT__/static/home/js/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="__ROOT__/static/plugins/layer.mobile-v2.0/layer_mobile/layer.js"></script>
    <link rel="stylesheet" type="text/css" href="__ROOT__/static/home/css/shop/base.css"/>
    <link rel="stylesheet" type="text/css" href="__ROOT__/static/home/css/shop/page.css"/>
    <link rel="stylesheet" type="text/css" href="__ROOT__/static/home/css/shop/all.css"/>
    <link rel="stylesheet" type="text/css" href="__ROOT__/static/home/css/shop/mui.min.css"/>
    <link rel="stylesheet" type="text/css" href="__ROOT__/static/home/css/shop/loaders.min.css"/>
    <link rel="stylesheet" type="text/css" href="__ROOT__/static/home/css/shop/loading.css"/>
    <link rel="stylesheet" type="text/css" href="__ROOT__/static/home/css/shop/slick/slick.css"/>
    <link rel="stylesheet" type="text/css" href="__ROOT__/static/home/css/shop/goodscats.css"/>
    <script type="text/javascript">
        $(window).load(function(){
            $(".loading").addClass("loader-chanage")
            $(".loading").fadeOut(300)
        })
    </script>
</head>
<!--loading页开始-->

<!--loading页结束-->
<body>
<header class="mui-bar mui-bar-nav report-header box-s" id="header">
    <a href="javascript:history.go(-1)"><i class="iconfont icon-fanhui fl"></i></a>
    <p>管理收货地址</p>
</header>
<div id="main" class="mui-clearfix contaniner"   style="margin-top: 60px;">

    {volist name='rows' id='data'  key='k'}
    <div class="addlist clearfloat">
        <div class="top clearfloat box-s">
            <ul>
                <li>
                    <span class="fl">{$data['user_name']}</span>
                    <span class="fr">{$data['phone']}</span>
                </li>
                <li>
                    {$data['address']}
                </li>
            </ul>
        </div>
        <div class="bottom clearfloat box-s">
            <section class="shopcar clearfloat">
                <div class=" " style="display: inline-block;height:24px;line-height: 24px;">
                        <input type="radio" name="sex" value="{$data['id']}"   {if condition="$data['default_status'] eq 1 "}checked="checked"{/if}
                               onclick="setDefault()"     style="width:20px;height:20px;"  >
                        <span class=" smradd "  >设为默认地址</span>
                </div>
                <div class="right fr clearfloat">
                    <a href="javascript:;" class="fr"  onclick="deleteAddress({$data['id']})" >
                        <i class="iconfont icon-lajixiang"></i>
                        删除
                    </a>
                    <a href="{:url('home/Address/updateAddress',array('id'=>$data['id']))}" class="fr">
                        <i class="iconfont icon-shouji"></i>
                        编辑
                    </a>
                </div>
            </section>
        </div>
    </div>
    {/volist}


</div>

    <a href="{:url('home/Address/addAddress')}" class="address-add fl">
        添加新地址
    </a>

</body>
</html>
<script>
    //删除默认地址
    function deleteAddress(id){
        var params={};
        params.id=id;
        layer.open({content:'确定删除吗？',btn: ['确定', '取消'],skin: 'footer',
            yes: function(index){
                $.post("{:url('home/Address/deleteAddress')}",params,function(data){
                    if( data>0 ){
                        layer.open({content: '操作成功',skin: 'msg',time: 3 });
                        location.href="{:url('home/Address/addressList')}";
                    }else if( data== -1 ){
                        layer.open({content: '操作失败',skin: 'msg',time: 3 });
                        return;
                    }
                })
            }
        });
    }
    //设为默认地址
    function setDefault(){
       var id= $('#main input[type="radio"]:checked').val();
        var params={};
        params.id=id;
        layer.open({content:'确定设为默认地址吗？',btn: ['确定', '取消'],skin: 'footer',
            yes: function(index){
                $.post("{:url('home/Address/setDefault')}",params,function(data){
                    if( data>0 ){
                        layer.open({content: '操作成功',skin: 'msg',time: 3 });
                    }else if( data== -1 ){
                        layer.open({content: '操作失败',skin: 'msg',time: 3 });
                        return;
                    }
                })
            }
        });
    }

</script>
